//
//  TL_ViewHelper.h
//
//  Created by Andrew on 2019/7/9.
//  Copyright © 2019 Andrew. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN


@interface TL_ViewHelper : NSObject

+ (UIWindow *)getKeyWindow;

+ (void)setCornerWithLeftTopCorner:(CGFloat)leftTop
                    rightTopCorner:(CGFloat)rigtTop
                  bottomLeftCorner:(CGFloat)bottemLeft
                 bottomRightCorner:(CGFloat)bottemRight
                              view:(UIView *)view
                             frame:(CGRect)frame;
/**
 上传图片处理
 */

+ (UIImage *)scaleImage:(UIImage *)image toScale:(float)scaleSize;

+ (NSString *)getBase64StringWithImageData:(NSData *)imageData;

+ (UIImage *)fixOrientation:(UIImage *)aImage;

+ (NSString *)imageExtensionWithFormatString:(NSString *)formatString;

+ (NSString *)audioExtensionWithFormatString:(NSString *)formatString;

+ (NSMutableAttributedString *)getSubContentWithOriginalContent:(NSMutableAttributedString *)originalContent labelWidth:(CGFloat)labelWidth labelMaxLine:(NSInteger)labelMaxLine;

+ (CGFloat)boundsWithFont:(UIFont *)font attributedText:(NSAttributedString *)attributedText needWidth:(CGFloat)needWidth lineSpacing:(CGFloat)lineSpacing;

/// 根据链接生成指定尺寸的二维码
+ (UIImage *)createNonInterpolatedUIImageFormCIImage:(NSString *)urlString withSize:(CGFloat)size;

/// 将UIView转换成UIImage
+ (UIImage * _Nullable)imageFromView:(UIView *)view;

//  获取icon
+ (NSString *)getIconImageName;
/*
 自适应frame
 */

// width
+ (CGFloat)getDynamicWidthWithLabel:(UILabel *)label;

+ (CGFloat)getDynamicWidthWithLabel:(UILabel *)label maxWidth:(CGFloat)maxWidth;

+ (CGFloat)getDynamicWidthWithLabelFont:(UIFont *)labelFont labelHeight:(CGFloat)labelHeight labelText:(NSString *)labelText;

+ (CGFloat)getDynamicWidthWithLabelFont:(UIFont *)labelFont labelHeight:(CGFloat)labelHeight labelText:(NSString *)labelText maxWidth:(CGFloat)maxWidth;

+ (CGFloat)getContentWidthWithContent:(NSString *)content withFont:(UIFont *)font;

// height
+ (CGFloat)getDynamicHeightWithLabel:(UILabel *)label;

+ (CGFloat)getDynamicHeightWithLabel:(UILabel *)label maxHeight:(CGFloat)maxHeight;

+ (CGFloat)getDynamicHeightWithLabelFont:(UIFont *)labelFont labelWidth:(CGFloat)labelWidth labelText:(NSString *)labelText;

+ (CGFloat)getDynamicHeightWithLabelFont:(UIFont *)labelFont labelWidth:(CGFloat)labelWidth labelText:(NSString *)labelText maxHeight:(CGFloat)maxHeight;

#pragma mark - 特殊字体

// 添加删除线
+ (NSMutableAttributedString *)addPartionLineWithString:(NSString *)string range:(NSRange)range;

// 添加下划线
+ (NSMutableAttributedString *)addUnderLineWithString:(NSString *)string range:(NSRange)range;

// 添加字体变大
+ (NSMutableAttributedString *)resetFontWithFont:(UIFont *)font string:(NSString *)string range:(NSRange)range;

// 添加字体变色
+ (NSMutableAttributedString *)resetColorWithColor:(UIColor *)color string:(NSString *)string range:(NSRange)range;

// 字体加粗
+ (NSMutableAttributedString *)resetBoldFontWithString:(NSString *)string range:(NSRange)range;

/*
 window
 */

+ (UIViewController *)getWindowRootController;

+ (UIViewController *)getCurrentViewController;

+ (UINavigationController * _Nullable)getCurrentNavigationController;

/*
 view
*/

+ (void)setStateBarLightStyle;

+ (void)setStateBarDefaultStyle;


/// 计算文字的宽高信息
/// @param fitSize 指定限制的尺寸
/// @param text 要计算的简单文本(NSString)或属性字符串(NSAttributedString)
/// @param numberOfLines 指定最大显示的行数
/// @param font 指定计算时文本的字体，当 text 是属性字符串时可以传nil
/// @param textAlignment 指定文本的对齐方式
/// @param lineBreakMode 指定多行时的断字模式
/// @param minimumScaleFactor 指定文本的最小缩放因子
/// @param shadowOffset 指定阴影的偏移位置
+ (CGSize)calcTextSize:(CGSize)fitSize
                  text:(id)text
         numberOfLines:(NSInteger)numberOfLines
                  font:(nullable UIFont *)font
         textAlignment:(NSTextAlignment)textAlignment
         lineBreakMode:(NSLineBreakMode)lineBreakMode
    minimumScaleFactor:(CGFloat)minimumScaleFactor
          shadowOffset:(CGSize)shadowOffset;

@end

NS_ASSUME_NONNULL_END
